import RSocket from '@tau/rsocket';

/**
 * 上传规则文件
 * @param {Buffer} fileData
 * @returns 成功返回字节数，否则异常
 */
export function uploadRule(fileData) {
  return RSocket.rc({
    route: 'dmn.rules.surcharge.upload',
    data: fileData,
    logLevel: 'trace',
  });
}

// 获取字典项
export function getDict({ search, pg }) {
  return RSocket.rs({
    route: 'dicts.taurusSurcharges.items',
    args: {
      search: { ...search },
      pg: { ...pg },
    },
  });
}

// 创建字典项
export function dictCreate(data) {
  return RSocket.rr({
    route: 'dicts.taurusSurcharges.items.create',
    data: {
      ...data,
    },
  });
}

// 修改字典项
export function dictUpdate(dictId, data) {
  return RSocket.rr({
    route: `dicts.${dictId}.items.update`,
    data: {
      ...data,
    },
  });
}

// 删除字典项
export function dictDelete(dictId, name) {
  return RSocket.rr({
    route: `dicts.${dictId}.items.${name}.delete`,
  });
}

